//package com.navi.loaddata.loadService.impl.measureData;
//
//import com.navi.loaddata.core.errorLog.ErrorCode;
//import com.navi.loaddata.core.etlException.ETLException2;
//import com.navi.loaddata.core.gpEntity.GpGlassF;
//import com.navi.loaddata.core.mysqlEntity.EtlConfDModel;
//import com.navi.loaddata.core.oracleEntity.EtlTtpResultV;
//import com.navi.loaddata.core.repository.impl.MySqlRepositoryImpl;
//import com.navi.loaddata.core.util.JdbcUtil;
//import org.apache.commons.dbutils.QueryRunner;
//import org.apache.commons.dbutils.handlers.BeanListHandler;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//
///**
// * Created by ghost on 2018/6/20.
// */
//@Service
//public class LoadTtpResultService {
//    @Autowired
//    private MySqlRepositoryImpl mysqlDao;
//    public void getTtpResultList(EtlConfDModel etlConfD, List<GpGlassF> glassList) {
//        QueryRunner query_mysql = JdbcUtil.getQueryRunner_mysql();
//        QueryRunner query_mes = JdbcUtil.getQueryRunner_mes();
//        List<EtlTtpResultV> mysqlList=new ArrayList<>();
//        HashMap<String,EtlTtpResultV> mysqlMap=new HashMap<>();
//        List<EtlTtpResultV> mesList=new ArrayList<>();
//
//        List<EtlTtpResultV> shiftXList=new ArrayList<>();
//        List<EtlTtpResultV> shiftYList=new ArrayList<>();
//        List<EtlTtpResultV> shiftXYList=new ArrayList<>();
//        try {
//            List<String> dcdataIdList="select "
//        String mysql="select  " +
//                " EXT_1 as productId," +
//                " EXT_2 as stepId," +
//                " ext_3 as defeinitonX," +
//                " ext_4 as defeinitonY," +
//                " ext_5 as shotId," +
//                " ext_6 as seqInShot" +
//                " from m_bis_data_d " +
//                " where DATA_CATE ='OVER'" +
//                " and VALID_FLG='Y'" +
//                " and EXT_1='"+glass.getProdId()+"'" +
//                " and EXT_2 ='"+glass.getOpeId()+"'";
//            mysqlList = query_mysql.query(mysql, new BeanListHandler<EtlTtpResultV>(EtlTtpResultV.class));
//            mysqlList.forEach(e->mysqlMap.put(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot(),e));
//        String mesSql="SELECT" +
//                " A.DCDATAID AS dcdataId," +
//                " A.processoperationname AS stepId," +
//                " A.materialname AS glassId," +
//                " A.processtime AS glassEndTime," +
//                " CASE WHEN A.recipename IS NULL THEN A.processoperationname ELSE A.recipename END  AS paramCollection," +
////                " NULL AS paramGroup," + //视图里没有
////                " 'SHIFT_X/SHIFT_Y/SHIFT_XY' AS paramName," +
//                " B.sitename AS siteName," +
////                " 'X,Y,0' AS paramValue," +
////                " 'DEFINITION_X+B.RESULT' AS X," +
////                " 'DEFINITION_Y+B.RESULT' AS Y," +
////                " 'MYSQL' AS definitionX," +
////                " 'MYSQL' AS definitionY," +
//                " MAX(CASE WHEN b.itemname='OLX_1' THEN B.RESULT ELSE NULL END) AS shiftX," +
//                " MAX(CASE WHEN b.itemname='OLY_1' THEN B.RESULT ELSE NULL END) AS shiftY," +
//                " A.productspecname AS productId " +
//                " FROM ( " +
//                " SELECT dcdataid,materialname,productspecname,recipename,processtime ,processoperationname " +
//                " FROM spc_dcdata " +
//                " WHERE 1=1 AND DCDATAID='"+dcdataId+"' " +
//                " )A  " +
//                " LEFT JOIN ( " +
//                " SELECT  " +
//                "   s.dcdataid, s.itemname,s.sitename,s.RESULT  " +
//                "   FROM spc_dcmeasuredataresult s " +
//                "   WHERE  1=1 AND s.DCDATAID ='"+dcdataId+"' " +
//                "   AND s.itemname IN('OLX_1','OLY_1')  " +
//                " )B ON B.dcdataid=A.dcdataid   " +
//                " WHERE trim(translate(nvl(B.sitename,'x'),'0123456789',' ')) is NULL " +
//                " GROUP BY  " +
//                " A.DCDATAID," +
//                " A.processoperationname," +
//                " A.materialname," +
//                " A.processtime," +
//                " CASE WHEN A.recipename IS NULL THEN A.processoperationname ELSE A.recipename END," +
//                " B.sitename," +
//                " A.productspecname";
//            mesList = query_mysql.query(mesSql, new BeanListHandler<EtlTtpResultV>(EtlTtpResultV.class));
//            mesList.forEach(e->{
//                double defeinitonX=mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getDefinitionX();
//                double defeinitonY=mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getDefinitionY();
//
//                EtlTtpResultV shiftX=new EtlTtpResultV();
//                shiftX.setDcdataId(e.getDcdataId());
//                shiftX.setGlassId(e.getGlassId());
//                shiftX.setStepId(e.getStepId());
//                shiftX.setGlassEndTime(e.getGlassEndTime());
//                shiftX.setParamCollection(e.getParamCollection());
//                shiftX.setParamName("SHIFT_X");
//                shiftX.setParamValue(defeinitonX);
//                shiftX.setSiteName(e.getSiteName());
//                shiftX.setX(e.getShiftX()+defeinitonX);
//                shiftX.setX(e.getShiftY()+defeinitonY);
//                shiftX.setDefinitionX(defeinitonX);
//                shiftX.setDefinitionY(defeinitonY);
//                shiftX.setShotId(mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getShotId());
//                shiftX.setSeqInShot(mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getSeqInShot());
//                shiftX.setShiftX(e.getShiftX());
//                shiftX.setShiftY(e.getShiftY());
//                shiftXList.add(shiftX);
//
//                EtlTtpResultV shiftY=new EtlTtpResultV();
//                shiftY.setDcdataId(e.getDcdataId());
//                shiftY.setGlassId(e.getGlassId());
//                shiftY.setStepId(e.getStepId());
//                shiftY.setGlassEndTime(e.getGlassEndTime());
//                shiftY.setParamCollection(e.getParamCollection());
//                shiftY.setParamName("SHIFT_Y");
//                shiftY.setParamValue(defeinitonY);
//                shiftY.setSiteName(e.getSiteName());
//                shiftY.setX(e.getShiftX()+defeinitonX);
//                shiftY.setX(e.getShiftY()+defeinitonY);
//                shiftY.setDefinitionX(defeinitonX);
//                shiftY.setDefinitionY(defeinitonY);
//                shiftY.setShotId(mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getShotId());
//                shiftY.setSeqInShot(mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getSeqInShot());
//                shiftY.setShiftX(e.getShiftX());
//                shiftY.setShiftY(e.getShiftY());
//                shiftYList.add(shiftY);
//
//                EtlTtpResultV shiftXY=new EtlTtpResultV();
//                shiftXY.setDcdataId(e.getDcdataId());
//                shiftXY.setGlassId(e.getGlassId());
//                shiftXY.setStepId(e.getStepId());
//                shiftXY.setGlassEndTime(e.getGlassEndTime());
//                shiftXY.setParamCollection(e.getParamCollection());
//                shiftXY.setParamName("SHIFT_XY");
//                shiftXY.setParamValue(Double.valueOf(0));
//                shiftXY.setSiteName(e.getSiteName());
//                shiftXY.setX(e.getShiftX()+defeinitonX);
//                shiftXY.setX(e.getShiftY()+defeinitonY);
//                shiftXY.setDefinitionX(defeinitonX);
//                shiftXY.setDefinitionY(defeinitonY);
//                shiftXY.setShotId(mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getShotId());
//                shiftXY.setSeqInShot(mysqlMap.get(e.getProductId()+"_"+e.getStepId()+"_"+e.getSeqInShot()).getSeqInShot());
//                shiftXY.setShiftX(e.getShiftX());
//                shiftXY.setShiftY(e.getShiftY());
//                shiftXYList.add(shiftXY);
//            });
//        }catch (Exception e){
//            throw new ETLException2(ErrorCode.,e);
//        }
//    }
//}
